﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.ComponentModel.DataAnnotations;


namespace Nightlife.Models
{
    public class User
    {
        [Key]
        public int ID { get; set; }

        [Required]
        public string Username { get; set; }


        public MembershipUser InnerUser
        {
            get
            {
                return Membership.GetUser(Username);
            }
            set
            {
                // Do Nothing
            }
        }

        public virtual ICollection<SpotModel> OwnedSpots { get; set; }
        public virtual ICollection<SpotModel> Favorites { get; set; }
        public virtual ICollection<User> Friends { get; set; }
        public virtual ICollection<SpotCommentModel> SpotComments { get; set; }
        public virtual ICollection<SpecialCommentModel> SpecialComments { get; set; }
        public virtual ICollection<SpecialModel> CreatedSpecials { get; set; }
        public virtual ICollection<Checkin> Checkins { get; set; }

        public bool IsFriend(User user)
        {
            return Friends.FirstOrDefault(u => u.ID == user.ID) != null;
        }

        public bool IsFriend(int id)
        {
            return Friends.FirstOrDefault(u => u.ID == id) != null;
        }
    }
}